<template>
  <div class="container">
    <!-- A: 顶部控制栏 -->
    <header class="header">
      <h2>保险欺诈知识图谱可视分析系统</h2>
      <div class="controls">
        <el-input v-model="searchQuery" placeholder="输入节点名..." style="width: 200px;" />
        <el-button type="primary" @click="searchNode">搜索</el-button>
        <el-select v-model="layout" @change="changeLayout">
          <el-option label="自动布局" value="cose" />
          <el-option label="层次布局" value="dagre" />
        </el-select>
        <el-button @click="resetView">重置</el-button>
      </div>
    </header>

    <!-- 主体内容：左右分栏 -->
    <div class="main-content">
      <!-- 左侧主区域 -->
      <div class="left-panel">
        <GraphPanel ref="graphPanel" :search-query="searchQuery" />
        <SankeyChart />
      </div>

      <!-- 右侧信息面板 -->
      <div class="right-panel">
        <StatsPanel />
        <IndustryChart />
        <RelationTable />
        <SummaryPanel />
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import GraphPanel from '@/components/GraphPanel.vue'
import SankeyChart from '@/components/SankeyChart.vue'
import StatsPanel from '@/components/StatsPanel.vue'
import IndustryChart from '@/components/IndustryChart.vue'
import RelationTable from '@/components/RelationTable.vue'
import SummaryPanel from '@/components/SummaryPanel.vue'

const searchQuery = ref('')
const layout = ref('cose')

const graphPanel = ref(null)

const searchNode = () => {
  if (graphPanel.value) {
    graphPanel.value.searchNode(searchQuery.value)
  }
}

const changeLayout = (val) => {
  if (graphPanel.value) {
    graphPanel.value.changeLayout(val)
  }
}

const resetView = () => {
  if (graphPanel.value) {
    graphPanel.value.resetView()
  }
}
</script>

<style scoped>
.container {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #f5f5f5;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: white;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.controls {
  display: flex;
  gap: 10px;
}

.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.left-panel {
  width: 70%;
  padding: 10px;
  box-sizing: border-box;
  overflow-y: auto;
}

.right-panel {
  width: 30%;
  padding: 10px;
  box-sizing: border-box;
  overflow-y: auto;
}

.panel {
  background: white;
  margin-bottom: 15px;
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
</style>